//
//  CZCycle.m
//  packDemo
//
//  Created by apple on 16/6/19.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "CZCycle.h"
#import "CZNetWorkTools.h"
@implementation CZCycle

+(instancetype)CycleWithDict:(NSDictionary *)dict{
    id obj = [[CZCycle alloc]init];
    [obj setValuesForKeysWithDictionary:dict];
    
    return obj;
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key{

}

+(void)cycleWithCompleteBlock:(void(^)(NSArray *))completeBlock{

    [[CZNetWorkTools shareNetWorkTools] objectListWithUrlString:@"http://c.m.163.com/nc/ad/headline/0-4.html" andParameters:nil andFinishBlock:^(id object) {
        if ([object isKindOfClass:[NSDictionary class]]) {
            NSDictionary *dict = (NSDictionary *)object;
            NSArray *arr = dict[@"headline_ad"];
            NSMutableArray *nmarray = [NSMutableArray array];
            for (NSDictionary *dict in arr) {
               CZCycle *model = [CZCycle CycleWithDict:dict];
                [nmarray addObject:model];
            }
            
            if (completeBlock) {
                completeBlock(nmarray.copy);
            }
        }
    }];


}


@end
